﻿using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Xml;
using PlugNT.Common;
using PlugNT.Custom;
using PlugNT.Cms.Page;

namespace PlugNT.Cms.Web.Admin.Pre_Global
{
    public partial class SetPayment : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //权限检测
            this.CheckPower();

            if (!IsPostBack)
            {
                InitConfigs();
            }
        }


        #region 初始化配置信息
        public void InitConfigs()
        {
            //支付宝更新配置
            alipay_account.Text = PlugNT.Custom.WebConfig.AlipaySelleremail;
            alipay_key.Text = PlugNT.Custom.WebConfig.AlipayKey;
            alipay_partner.Text = PlugNT.Custom.WebConfig.AlipayPartner;
            int tCount = alipay_interface.Items.Count; 
            for (int i = 0; i < tCount; i++)
            {
                if (alipay_interface.Items[i].Value == PlugNT.Custom.WebConfig.AlipayType)
                {
                    alipay_interface.SelectedIndex = i;
                    break;
                }
            }

        }
        #endregion


        #region 支付配置
        protected void payUpdate_Click(object sender, EventArgs e)
        {
            //支付宝更新配置
            string selleremail = alipay_account.Text.Trim();
            string key = alipay_key.Text.Trim();
            string partner = alipay_partner.Text.Trim();
            string type = alipay_interface.SelectedValue.Trim();
            WebSeting.UpdateAlipay(key, selleremail, partner, type);


            Response.Redirect("../Message.aspx?message=支付宝配置修改成功！&z=yes");
        }
        #endregion

    }
}
